package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.IndustryEducation;
import com.ruoyi.system.service.IIndustryEducationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查看内容Controller
 * 
 * @author coderChen
 * @date 2024-01-09
 */
@RestController
@RequestMapping("/system/education")
public class IndustryEducationController extends BaseController
{
    @Autowired
    private IIndustryEducationService industryEducationService;

    /**
     * 查询查看内容列表
     */
    @PreAuthorize("@ss.hasPermi('system:education:list')")
    @GetMapping("/list")
    public TableDataInfo list(IndustryEducation industryEducation)
    {
        startPage();
        List<IndustryEducation> list = industryEducationService.selectIndustryEducationList(industryEducation);
        return getDataTable(list);
    }

    /**
     * 导出查看内容列表
     */
    @PreAuthorize("@ss.hasPermi('system:education:export')")
    @Log(title = "查看内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IndustryEducation industryEducation)
    {
        List<IndustryEducation> list = industryEducationService.selectIndustryEducationList(industryEducation);
        ExcelUtil<IndustryEducation> util = new ExcelUtil<IndustryEducation>(IndustryEducation.class);
        util.exportExcel(response, list, "查看内容数据");
    }

    /**
     * 获取查看内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:education:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(industryEducationService.selectIndustryEducationById(id));
    }

    /**
     * 新增查看内容
     */
    @PreAuthorize("@ss.hasPermi('system:education:add')")
    @Log(title = "查看内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IndustryEducation industryEducation)
    {
        industryEducation.setCreateBy(getUsername());
        return toAjax(industryEducationService.insertIndustryEducation(industryEducation));
    }

    /**
     * 修改查看内容
     */
    @PreAuthorize("@ss.hasPermi('system:education:edit')")
    @Log(title = "查看内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IndustryEducation industryEducation)
    {
        industryEducation.setCreateBy(getUsername());
        return toAjax(industryEducationService.updateIndustryEducation(industryEducation));
    }

    /**
     * 删除查看内容
     */
    @PreAuthorize("@ss.hasPermi('system:education:remove')")
    @Log(title = "查看内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(industryEducationService.deleteIndustryEducationByIds(ids));
    }
}
